package com.example.client_anna.module.branch_home;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.client_anna.network.room.database.ClientDataBase;
import com.example.client_anna.network.room.entity.Goods;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author cy
 * @email 272884043@qq.com
 * @date 2021/10/19
 */
//店铺商品购买数据记录
public class GoodsViewModel extends AndroidViewModel {
    //数据库
    private ClientDataBase clientDataBase;

    private LiveData<List<Goods>> listGoods;

    public GoodsViewModel(@NonNull @NotNull Application application) {
        super(application);
        //初始化数据库实例
        clientDataBase = ClientDataBase.getDataBase(application);
        listGoods = clientDataBase.getGoodsDao().queryGoodsByLiveData();
    }
    public LiveData<List<Goods>> getListGoods(){
        return listGoods;
    }
}
